package Messages;

import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.jdbc.ResultSet;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * this class implements the updating telephone in db
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class MessageNewTelephone {
	private ConnectionToClient client ;
	private String tel;
	private ResultSet rs;
	public Statement stmt;
	public SQLConnection conn = new SQLConnection();
/**
 * constractor of this class 
 * @param client
 */
public MessageNewTelephone() {
	super();
	//this.client = client;
}
/**
 * edit new telephone to the DB 
 * @param str
 * @throws SQLException
 * @throws IOException
 */

public String edittelephone(String[] str) throws SQLException, IOException {
	
	String str1 ="NewTelephone";
	
	SQLConnection sc = new SQLConnection();
	java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("Update DB1.subscriber SET telephone=? WHERE ID=?");
	ps.setString(1, str[2]);
	ps.setString(2, str[1]);
	ps.executeUpdate();
	
	
	ps.close();
	
	return str1; 
	
	





}
public String getphone() throws SQLException, IOException {
	stmt = conn.getConnection().createStatement();
	java.sql.ResultSet rs1= stmt.executeQuery("select * from db1.subscriber");
	return (this.tel=tel=rs1.getString(4));
	
}



}